
lunbo2('#rightcontext1', '#headcontentright-span1', '#headcontentright-span2', '#headcontentright-num1')
lunbo2('#rightcontext2', '#headcontentright-span3', '#headcontentright-span4', '#headcontentright-num2')
lunbo2('#rightcontext3', '#headcontentright-span5', '#headcontentright-span6', '#headcontentright-num3')

function lunbo2(urId, prespan, nextspan, numspan) {
  var rightcontext = document.querySelector(urId)
  var carouselBoxs = rightcontext.querySelectorAll('.carousel-box')
  var pre = document.querySelector(prespan)
  var next = document.querySelector(nextspan)
  var num = document.querySelector(numspan)
  var index = 0
  next.onclick = function () {
    if (num.innerHTML == carouselBoxs.length - 1) {
      num.innerHTML = 0
    }
    num.innerHTML++
    if (index == carouselBoxs.length - 1) {
      index = 0
      rightcontext.style.left = -940 * index + 'px'
    }
    index++
    var target = -940 * index
    moveAnimation2(rightcontext, target)
  }

  pre.onclick = function () {
    if (num.innerHTML == 1) {
      num.innerHTML = carouselBoxs.length
    }
    num.innerHTML--
    if (index == 0) {
      index = carouselBoxs.length - 1
      rightcontext.style.left = -940 * index + 'px'
    }
    index--
    var target = -940 * index
    moveAnimation2(rightcontext, target)
  }
}

